package com.elinkway.infinitemovies.ui.activity.play;

import android.os.Handler;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;

import com.elinkway.infinitemovies.utils.Utils;

public class ScrollChangeListener implements OnScrollListener{
	
	private Handler mHandler;
	
	public ScrollChangeListener(Handler handler) {
		mHandler = handler;
	}

	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {
		switch (scrollState) {
		// 开始滚动
		case OnScrollListener.SCROLL_STATE_FLING:
			mHandler.removeMessages(Utils.DISSMISS_MEDIACONTROLLER);
			break;
		// 停止滚动
		case OnScrollListener.SCROLL_STATE_IDLE:
			mHandler.sendEmptyMessageDelayed(
					Utils.DISSMISS_MEDIACONTROLLER,
					Utils.MEDIA_CONTROLLER_DISMISS_TIME);
			break;
		default:
			break;
		}
	}

	@Override
	public void onScroll(AbsListView view, int firstVisibleItem,
			int visibleItemCount, int totalItemCount) {

	}

}
